﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using BusinessLayer.FindArtInfo.Entities;
using DBHelper;

namespace BusinessLayer.FindArtInfo
{
    public class ArtLinksBL
    {
        private readonly DbHelper _db;

        public ArtLinksBL()
        {
            _db = new DbHelper(new DbConfig().DbFindArtInfoConnectionString);         
        }

        public List<ArtLinks> GetByCategory(int categoryId)
        {
            var oCommand = new SqlCommand("sp_ArtLinks_SelectByCategory") { CommandType = CommandType.StoredProcedure };
            oCommand.Parameters.Add(new SqlParameter("@CategoryId", categoryId));
            var artLink = _db.GetList<ArtLinks>(oCommand);
            return artLink; 
        }

        public List<ArtLinks> Search(string keyWord,int categoryId,int countryId)
        {
            var oCommand = new SqlCommand("sp_ArtLinks_Search") { CommandType = CommandType.StoredProcedure };
            oCommand.Parameters.Add(new SqlParameter("@KeyWord", keyWord));
            oCommand.Parameters.Add(new SqlParameter("@CategoryId", categoryId));
            oCommand.Parameters.Add(new SqlParameter("@CountryId", countryId));
            var artLink = _db.GetList<ArtLinks>(oCommand);
            return artLink;
        }
    }
}
